import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
	redirect:"/login"
  },	
  {
    path: '/login',
  	component:() => import('../views/Login.vue'),
  },	
  {
    path: '/home',
    name: 'Home',
    component:() => import('../views/Home.vue'),
	children:[
    {
		  path: '/goods',
		  name: 'goods',
		  component:() => import('../views/home/Goods.vue'),
		  meta:{comp:"/goods",pathname:"商品管理",name:"商品列表"}
		},
    {
		  path: '/orders',
		  name: 'orders',
		  component:() => import('../views/home/Orders.vue'),
		  meta:{comp:"/orders",pathname:"订单管理",name:"订单列表"}
		},
    {
		  path: '/user',
		  name: 'user',
		  component:() => import('../views/home/User.vue'),
		  meta:{comp:"/user",pathname:"权限管理",name:"用户列表"}
		},
    {
		  path: '/wxuser',
		  name: 'wxuser',
		  component:() => import('../views/home/WxUser.vue'),
		  meta:{comp:"/wxuser",pathname:"权限管理",name:"微信用户"}
		},
    {
		  path: '/notices',
		  name: 'notices',
		  component:() => import('../views/home/Notices.vue'),
		  meta:{comp:"/notices",pathname:"公告管理",name:"发布公告"}
		},
	]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
export default router
